import Vue from 'vue'
import Router from 'vue-router'
import store from '../store'
import {Dialog} from 'vant'

import myCompanyRouter from './modules/myCompany'

Vue.use(Router)

//获取原型对象上的push函数
const originalPush = Router.prototype.push
//修改原型对象中的push方法
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

// 路由链接
const routes = [
  
  {
    path: '/',
    name: 'home',
    component: () => import('../views/home/home'), // 路由懒加载
    meta: {
      title: '首页', // 页面标题
      // https://zhuanlan.zhihu.com/p/96740001
      keepAlive: true, // keep-alive 缓存的标识
      isShowTabBar: true
    }
  },
  {
    path: '/mine',
    name: 'mine',
    component: () => import('../views/mine/mine'),
    meta: {
      title: '我的',
      keepAlive: false,
      isShowTabBar: true
    }
  },
  {
    path: '/tests',
    name: 'test',
    component: () => import('../views/home/test'), // 路由懒加载
    meta: {
      title: '扫码', // 页面标题
      keepAlive: false, // keep-alive 缓存的标识
      isShowTabBar: true
    }
  },

  {
    path: '/daohan',
    name: 'daohan',
    component: () => import('../views/home/daohan'), // 路由懒加载
    meta: {
      title: '导航', // 页面标题
      keepAlive: false, // keep-alive 缓存的标识
      isShowTabBar: true
    }
  },

  {
    path: '/messages',
    name: 'messages',
    component: () => import('@/views/messages/messages'), // 路由懒加载
    meta: {
      title: '消息', // 页面标题
      keepAlive: true, // keep-alive 标识
      isShowTabBar: true,
      requiresAuth: true
    }
  },
  {
    path: '/complaint',
    name: 'complaint',
    component: () => import('@/views/complaint/complaint'),
    meta: {
      title: '投诉建议',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/complaintList',
    name: 'complaintList',
    component: () => import('@/views/complaintList/complaintList'),
    meta: {
      title: '投诉建议列表',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/chat',
    name: 'chat',
    component: () => import('@/views/messages/chat'), // 路由懒加载
    meta: {
      title: '聊天', // 页面标题
      keepAlive: false, // keep-alive 标识
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/headDetail',
    name: 'headDetail',
    component: () => import('@/views/messages/headDetail'), // 路由懒加载
    meta: {
      title: '个人信息', // 页面标题
      keepAlive: true, // keep-alive 标识
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/addFreid',
    name: 'addFreid',
    component: () => import('@/views/messages/addFreid'), // 路由懒加载
    meta: {
      title: '添加好友', // 页面标题
      keepAlive: false, // keep-alive 标识
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/limitFriend',
    name: 'limitFriend',
    component: () => import('@/views/messages/limitFriend'), // 路由懒加载
    meta: {
      title: '朋友权限', // 页面标题
      keepAlive: false, // keep-alive 标识
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/setRemark',
    name: 'setRemark',
    component: () => import('@/views/messages/setRemark'), // 路由懒加载
    meta: {
      title: '设置备注和标签', // 页面标题
      keepAlive: false, // keep-alive 标识
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/friendInfo',
    name: 'friendInfo',
    component: () => import('@/views/messages/friendInfo'), // 路由懒加载
    meta: {
      title: '好友列表', // 页面标题
      keepAlive: false, // keep-alive 标识
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/customer_service',
    name: 'customer_service',
    component: () => import('@/views/messages/customer_service'), // 路由懒加载
    meta: {
      title: '客服列表', // 页面标题
      keepAlive: false, // keep-alive 标识
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/addFreidList',
    name: 'addFreidList',
    component: () => import('@/views/messages/addFreidList'), // 路由懒加载
    meta: {
      title: '好友列表', // 页面标题
      keepAlive: false, // keep-alive 标识
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/publish',
    name: 'publish',
    component: () => import('../views/publish/publish'), // 路由懒加载
    meta: {
      title: '发布', // 页面标题
      keepAlive: false, // keep-alive 标识
      isShowTabBar: true,
      requiresAuth: true
    }
  },
  {
    path: '/market',
    name: 'market',
    component: () => import('@/views/market/market'),
    meta: {
      title: '商城',
      keepAlive: false,
      isShowTabBar: true,
      requiresAuth: true
    }
  },
  
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/login/login'),
    meta: {
      title: '登录',
      keepAlive: false,
      isShowTabBar: false
    }
  },
  {
    path: '/register',
    name: 'register',
    component: () => import('../views/register/register'),
    meta: {
      title: '注册',
      keepAlive: true,
      isShowTabBar: false
    }
  },
  {
    path: '/welcome',
    name: 'welcome',
    component: () => import('../views/welcome/welcome'),
    /*beforeEnter (to, from, next) {
      console.log('当前前往', to)
      // 得到当前路由信息对象
      // const route = router.currentRoute  // route就是from
      const allUserInfo = window.sessionStorage.getItem('userInfo');
      console.log('用户信息', allUserInfo)
      if (to.name === 'welcome' && allUserInfo){
        next('/')
      } else {
        next()
      }
    },*/
    meta: {
      title: '欢迎页',
      keepAlive: true,
      isShowTabBar: false
    }
  },
  {
    path: '/info',
    name: 'info',
    component: () => import('../views/info/info'),
    meta: {
      title: '招聘信息收集',
      keepAlive: false,
      isShowTabBar: false
    }
  },
  {
    path: '/userAgreement',
    name: 'userAgreement',
    component: () => import('../views/register/userAgreement'),
    meta: {
      title: '用户注册协议',
      keepAlive: false,
      isShowTabBar: false
    }
  },
  {
    path: '/privacyAgreement',
    name: 'privacyAgreement',
    component: () => import('../views/register/privacyAgreement'),
    meta: {
      title: '用户隐私协议',
      keepAlive: false,
      isShowTabBar: false
    }
  },
  {
    path: '/findPwd',
    name: 'findPwd',
    component: () => import('@/views/findPwd/findPwd'),
    meta: {
      title: '找回密码',
      keepAlive: false,
      isShowTabBar: false
    }
  },
  {
    path: '/subAccount',
    name: 'subAccount',
    component: () => import('@/views/subAccount/subAccount'),
    meta: {
      title: '子账号登录',
      keepAlive: false,
      isShowTabBar: false
    }
  },
  {
    path: '/jobDetail',
    name: 'jobDetail',
    component: () => import('../views/jobDetail/jobDetail'),
    meta: {
      title: '职位详情',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: false
    }
  },
  /*{
    path: '/seekJob',
    name: 'seekJob',
    component: () => import('../views/seekJob/seekJob'),
    meta: {
      title: '找工作（全职、兼职、小时工）',
      keepAlive: false,
      isShowTabBar: false
    }
  },*/
  {
    path: '/address',
    name: 'selectAddress',
    component: () => import('@/views/selectAddress/selectAddress'),
    meta: {
      title: '地址',
      keepAlive: false,
      isShowTabBar: false
    }
  },
  {
    path: '/map',
    name: 'map',
    component: () => import('../views/useMap/useMap'),
    meta: {
      title: '地图定位',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: false
    }
  },
  {
    path: '/allTypeJobs',
    name: 'allTypeJobs',
    component: () => import('@/views/allTypeJobs/allTypeJobs'),
    meta: {
      title: '发布全职、兼职、小时工',
      // 注: 此处不能缓存组件, 不然拿不到params参数，除非: 1、使用query参数; 2、参考选择地址（selectAddress）页面的方法
      keepAlive: false,
      isShowTabBar: false
    }
  },
  {
    path: '/profile',
    name: 'profile',
    component: () => import('@/views/profile/profile'),
    meta: {
      title: '个人资料',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/enterpriseAuth',
    name: 'enterpriseAuth',
    component: () => import('../views/enterpriseAuth/enterpriseAuth'),
    meta: {
      title: '企业认证',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/enterpriseManage',
    name: 'enterpriseManage',
    component: () => import('@/views/enterpriseManage/enterpriseManage'),
    meta: {
      title: '企业管理',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/enterpriseDetail/:id',
    name: 'enterpriseDetail',
    component: () => import('@/views/enterpriseManage/enterpriseDetail'),
    meta: {
      title: '企业认证详情',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/personalAuth',
    name: 'personalAuth',
    component: () => import('@/views/personalAuth/personalAuth'),
    meta: {
      title: '个人认证',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/myEarnings',
    name: 'myEarnings',
    component: () => import('@/views/myEarnings/myEarnings'),
    meta: {
      title: '我的收益',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/changePwd',
    name: 'changePwd',
    component: () => import('@/views/changePwd/changePwd'),
    meta: {
      title: '修改密码',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/updateProfile',
    name: 'updateProfile',
    component: () => import('@/views/updateProfile/updateProfile'),
    meta: {
      title: '修改个人资料',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/setcaShinfo',
    name: 'setcaShinfo',
    component: () => import('@/views/profile/setcaShinfo'),
    meta: {
      title: '提现设置',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/displayProfile',
    name: 'displayProfile',
    component: () => import('@/views/displayProfile/displayProfile'),
    meta: {
      title: '展示个人资料',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/payPwd',
    name: 'payPwd',
    component: () => import('@/views/payPwd/payPwd'),
    meta: {
      title: '支付密码',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/privacySetting',
    name: 'privacySetting',
    component: () => import('@/views/privacySetting/privacySetting'),
    meta: {
      title: '隐私设置',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/privacyPwd',
    name: 'privacyPwd',
    component: () => import('@/views/privacyPwd/privacyPwd'),
    meta: {
      title: '隐私密码',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/recommend_persons',
    name: 'recommendPersons',
    component: () => import('@/views/recommendPersons/recommendPersons'),
    meta: {
      title: '我的下家',
      keepAlive: true,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/myCompany',
    redirect: '/myCompany/companyHome',
    name: 'myCompany',
    component: () => import('../views/myCompany/myCompany'),
    meta: {
      title: '我的公司',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    },
    children: [
      {
        path: 'companyHome',
        name: 'companyHome',
        component: () => import('.././views/myCompany/companyHome/companyHome'),
        meta: {
          title: '我的公司',
          keepAlive: false,
          isShowTabBar: false,
          requiresAuth: true
        }
      },
      {
        path: 'recruitmentManagement',
        name: 'recruitmentManagement',
        component: () => import('../views/myCompany/recruitmentManagement/recruitmentManagement'),
        meta: {
          keepAlive: false
        }
      },
      {
        path: 'upstreamDownstreamManagement',
        name: 'upstreamDownstreamManagement',
        component: () => import('../views/myCompany/upstreamDownstreamManagement/upstreamDownstreamManagement'),
        meta: {
          keepAlive: false,
          isShowTabBar: false,
          requiresAuth: true
        }
      },
      {
        path: 'myBlackList',
        name: 'myBlackList',
        component: () => import('../views/myCompany/upstreamDownstreamManagement/myBlackList')
      },
      {
        path: 'invitationsIssued',
        name: 'invitationsIssued',
        component: () => import('../views/myCompany/upstreamDownstreamManagement/invitationsIssued')
      },
      {
        path: 'getApplyCost',
        name: 'getApplyCost',
        component: () => import('../views/myCompany/upstreamDownstreamManagement/getApplyCost')
      },
      {
        path: 'sendApplyCost',
        name: 'sendApplyCost',
        component: () => import('../views/myCompany/upstreamDownstreamManagement/sendApplyCost')
      },
      {
        path: 'companyStaffManagement',
        name: 'companyStaffManagement',
        component: () => import('../views/myCompany/companyStaffManagement/companyStaffManagement')
      }
    ]
  },
  {
    path: '/companyNewAccount/:id', //公司员工管理--新建子账号
    name: 'companyNewAccount',
    component: () => import('@/views/myCompany/companyStaffManagement/companyNewAccount.vue'),
    meta: {
      title: '公司员工管理',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true,
      isDetailShow: true
    }
  },
  {
    path: '/addSubCcount', //公司员工管理--新建子账号
    name: 'addSubCcount',
    component: () => import('@/views/myCompany/companyStaffManagement/addSubCcount.vue'),
    meta: {
      title: '新建账号',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true,
      isDetailShow: true
    }
  },
  {
    path: '/comNewDepartment/:id', //公司员工管理--新建部门
    name: 'comNewDepartment',
    component: () => import('@/views/myCompany/companyStaffManagement/comNewDepartment.vue'),
    meta: {
      title: '新建部门',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/companyCheckbox/:id', //公司员工管理--新建部门
    name: 'companyCheckbox',
    component: () => import('@/views/myCompany/companyStaffManagement/companyCheckbox.vue'),
    meta: {
      title: '权限',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true,
      isDetailShow: true
    }
  },
  {
    path: '/myCompany/recruitStaffList',
    name: 'recruitStaffList',
    component: () => import('../views/myCompany/recruitmentManagement/recruitStaffList'),
    meta: {
      title: '招聘员工列表',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/myCompany/staffRollCall',
    name: 'staffRollCall',
    component: () => import('@/views/myCompany/recruitmentManagement/staffRollCall'),
    meta: {
      title: '点名',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/myCompany/rollCallQrCode',
    name: 'rollCallQrCode',
    component: () => import('@/views/myCompany/recruitmentManagement/rollCallQrCode'),
    meta: {
      title: '点名码',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/myCompany/contractAgreement',
    name: 'contractAgreement',
    component: () => import('@/views/myCompany/recruitmentManagement/contractAgreement'),
    meta: {
      title: '合同协议',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/myCompany/workInfo',
    name: 'workInfo',
    component: () => import('@/views/myCompany/recruitmentManagement/workInfo'),
    meta: {
      title: '工作信息',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/myCompany/advaceInfo',
    name: 'advaceInfo',
    component: () => import('../views/myCompany/recruitmentManagement/advaceInfo'),
    meta: {
      title: '借支信息',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/myCompany/salary',
    name: 'salary',
    component: () => import('../views/myCompany/recruitmentManagement/salary'),
    meta: {
      title: '工资信息',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/myCompany/blackList',
    name: 'blackList',
    component: () => import('../views/myCompany/recruitmentManagement/blackList'),
    meta: {
      title: '招聘员工黑名单',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/myCompany/salaryModel/:companyID',
    name: 'salaryModel',
    component: () => import('../views/myCompany/recruitmentManagement/salaryModel'),
    meta: {
      title: '工资条模版',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/myCompany/resign',
    name: 'resign',
    component: () => import('../views/myCompany/recruitmentManagement/resign'),
    meta: {
      title: '辞职申请',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/myCompany/resignLog',
    name: 'resignLog',
    component: () => import('../views/myCompany/recruitmentManagement/resignLog'),
    meta: {
      title: '申请记录',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/myCompany/addsalaryModel/:companyID',
    name: 'addsalaryModel',
    component: () => import('../views/myCompany/recruitmentManagement/addsalaryModel'),
    meta: {
      title: '新建工资条模版',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/myCompany/insertSalary',
    name: 'insertSalary',
    component: () => import('../views/myCompany/recruitmentManagement/insertSalary.vue'),
    meta: {
      title: '输入工资条模版',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/myCompany/upAndDownstreamCompany',
    name: 'upAndDownstreamCompany',
    component: () => import('../views/myCompany/upstreamDownstreamManagement/upAndDownstreamCompany'),
    meta: {
      title: '上下游公司列表',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },

  {
    path: '/myCompany/getOrPayFeeRecord',
    name: 'getOrPayFeeRecord',
    component: () => import('../views/myCompany/upstreamDownstreamManagement/getOrPayFeeRecord'),
    meta: {
      title: '上下游公司列表',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/myCompany/ratingList',
    name: 'ratingList',
    component: () => import('@/views/myCompany/companyHome/ratingList'),
    meta: {
      title: '公司评分',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/myCompany/canShareAndAuditState',
    name: 'canShareAndAuditState',
    component: () => import('@/views/myCompany/companyHome/canShareAndAuditState'),
    meta: {
      title: '转发和发布审核状态',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/myCompany/Introduce',
    name: 'comIntroduce',
    component: () => import('@/views/myCompany/companyHome/Introduce'),
    meta: {
      title: '公司介绍',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/myCompany/channel',
    name: 'channel',
    component: () => import('@/views/myCompany/companyHome/channel'),
    meta: {
      title: '设置线下报名渠道来源',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/myCompany/jobSheet',
    name: 'jobSheet',
    component: () => import('@/views/myCompany/companyHome/jobSheet'),
    meta: {
      title: '我的收集表',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/myCompany/Notice',
    name: 'comNotice',
    component: () => import('@/views/myCompany/companyHome/comNotice'),
    meta: {
      title: '我的公司公告',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/myCompany/upNotice/:id',
    name: 'comUpNotice',
    component: () => import('@/views/myCompany/companyHome/comUpNotice'),
    meta: {
      title: '上传公司公告',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/myCompany/MyPublish',
    name: 'MyPublish',
    component: () => import('../views/myCompany/companyHome/MyPublish'),
    meta: {
      title: '我的发布',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/myCompany/notAuthShare',
    name: 'notAuthShare',
    component: () => import('@/views/myCompany/companyHome/notAuthShare'),
    meta: {
      title: '谁不可转发',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/myCompany/addNotAuthShare',
    name: 'addNotAuthShare',
    component: () => import('@/views/myCompany/companyHome/addNotAuthShare'),
    meta: {
      title: '新增谁不可转发',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },

  {
    path: '/grade',
    name: 'grade',
    component: () => import('@/views/grade/grade'),
    meta: {
      title: '公司评分',
      keepAlive: false,
      isShowTabBar: false
    }
  },

  {
    path: '/hasSignUpList',
    name: 'hasSignUpList',
    component: () => import('../views/hasSignUp/hasSignUpList'),
    meta: {
      title: '已报名',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/hasWorkedList',
    name: 'hasWorkedList',
    component: () => import('@/views/hasWorked/hasWorkedList'),
    meta: {
      title: '已工作',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/rechange',
    name: 'rechange',
    component: () => import('@/views/rechange/rechange'),
    meta: {
      title: '充值',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/qode',
    name: 'qode',
    component: () => import('@/views/qode/qode'),
    meta: {
      title: '扫码点名',
      keepAlive: false,
      isShowTabBar: false
      // requiresAuth: true
    }
  },
  {
    path: '/packet',
    name: 'packet',
    component: () => import('@/views/packet/packet'),
    meta: {
      title: '钱包',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/zzbPacket',
    name: 'zzbPacket',
    component: () => import('@/views/zzbPacket/zzbPacket'),
    meta: {
      title: '总资本',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/withdraw',
    name: 'withdraw',
    component: () => import('@/views/withdraw/withdraw'),
    meta: {
      title: '提现',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/wallet',
    name: 'wallet',
    component: () => import('@/views/wallet/wallet'),
    meta: {
      title: '钱包总记录',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/addCard',
    name: 'addCard',
    component: () => import('@/views/addCard/addCard'),
    meta: {
      title: '添加银行卡',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/lendMoney',
    name: 'lendMoney',
    component: () => import('@/views/lendMoney/lendMoney'),
    meta: {
      title: '申请借支',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/lendMoneyDetail/:id',
    name: 'lendMoneyDetail',
    component: () => import('@/views/lendMoney/lendMoneyDetail'),
    meta: {
      title: '借支详情',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/lendMoneyRecords',
    name: 'lendMoneyRecords',
    component: () => import('@/views/lendMoney/lendMoneyRecords'),
    meta: {
      title: '借支申请记录',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/applyLendMoney',
    name: 'applyLendMoney',
    component: () => import('@/views/lendMoney/applyLendMoney'),
    meta: {
      title: '提交借支申请',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/withdrawalRecords/:id',
    name: 'withdrawalRecords',
    component: () => import('@/views/lendMoney/withdrawalRecords'),
    meta: {
      title: '提现记录',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/myCompany/salaryPay',
    name: 'salaryPay',
    component: () => import('../views/myCompany/recruitmentManagement/salaryPay'),
    meta: {
      title: '支付工资',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/myCompany/lendMoneyPay',
    name: 'lendMoneyPay',
    component: () => import('../views/myCompany/recruitmentManagement/lendMoneyPay'),
    meta: {
      title: '支付借支金额',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/myCompany/feePay',
    name: 'feePay',
    component: () => import('../views/myCompany/recruitmentManagement/feePay'),
    meta: {
      title: '支付代招费',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/salaryList',
    name: 'salaryList',
    component: () => import('../views/myCompany/recruitmentManagement/salaryList'),
    meta: {
      title: '工资记录',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/feePayList',
    name: 'feePayList',
    component: () => import('../views/myCompany/recruitmentManagement/feePayList'),
    meta: {
      title: '代招费记录',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/queryRecords/:id',
    name: 'queryRecords',
    component: () => import('../views/queryRecords/queryRecordsByDate'),
    meta: {
      title: '已报名、已工作、申请借支、工资结算的查询页',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/searchRecords/:id',
    name: 'searchRecords',
    component: () => import('../views/queryRecords/searchRecords'),
    meta: {
      title: '已报名、已工作、申请借支、工资结算的搜索页',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },

  {
    path: '/wageSettlement',
    name: 'wageSettlement',
    component: () => import('@/views/wageSettlement/wageSettlement'),
    meta: {
      title: '工作结算',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/wageDetail/:id',
    name: 'wageDetail',
    component: () => import('@/views/wageSettlement/wageDetail'),
    meta: {
      title: '工资详情',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/rate/:id',
    name: 'rate',
    component: () => import('@/views/wageSettlement/rate'),
    meta: {
      title: '公司评价',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/recommend_fee_record',
    name: 'recommendFeeRecord',
    component: () => import('@/views/recommendPersons/recommendFeeRecord'),
    meta: {
      title: '代招费总记录',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/recommend_person_Detail/:id',
    name: 'recommend_personDetail',
    component: () => import('@/views/recommendPersons/personDetail'),
    meta: {
      title: '我的下家详情',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/downstreamUsers',
    name: 'downstreamUsers',
    component: () => import('@/views/recommendPersons/downstreamUsers'),
    meta: {
      title: '他推广的用户',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/applyStockForHe',
    name: 'applyStockForHe',
    component: () => import('@/views/recommendPersons/applyStockForHe'),
    meta: {
      title: '他申请的股份',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },

  {
    path: '/applyDetail',
    name: 'applyDetail',
    component: () => import('@/views/recommendPersons/applyDetail'),
    meta: {
      title: '申请详情',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },

  {
    path: '/receivedStock',
    name: 'receivedStock',
    component: () => import('@/views/recommendPersons/receivedStock'),
    meta: {
      title: '我已领取的股份总数',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/unReceivedStock',
    name: 'unReceivedStock',
    component: () => import('@/views/recommendPersons/unReceivedStock'),
    meta: {
      title: '我待领取的股份总数',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/unReceivedStock1',
    name: 'unReceivedStock1',
    component: () => import('@/views/recommendPersons/unReceivedStock'),
    meta: {
      title: '我待领取的股份总数',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/unReceivedStock2',
    name: 'unReceivedStock2',
    component: () => import('@/views/recommendPersons/unReceivedStock'),
    meta: {
      title: '我待领取的股份总数',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/unReceivedStockbdyh',
    name: 'unReceivedStockbdyh',
    component: () => import('@/views/recommendPersons/unReceivedStockbdyh'),
    meta: {
      title: '我待领取的股份总数',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  
  {
    path: '/verticalPoster',
    name: 'verticalPoster',
    component: () => import('@/views/poster/verticalPoster'),
    meta: {
      title: '竖版海报',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/guide',
    name: 'guide',
    component: () => import('@/views/poster/guide'),
    meta: {
      title: '引导页',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },

  {
    path: '/verticalPoster/detail',
    name: 'verticalPosterDetail',
    component: () => import('@/views/poster/index_v'),
    meta: {
      title: '竖版海报的详情',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/horizontalPoster',
    name: 'horizontalPoster',
    component: () => import('@/views/poster/horizontalPoster'),
    meta: {
      title: '横版海报',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/horizontalPoster/detail',
    name: 'horizontalPosterDetail',
    component: () => import('@/views/poster/index_h'),
    meta: {
      title: '横版海报的详情',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/groupStock',
    name: 'groupStock',
    component: () => import('@/views/groupStock/groupStock'),
    meta: {
      title: '集团股份',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/applyStock',
    name: 'applyStock',
    component: () => import('@/views/groupStock/commonUser/applyStock'),
    meta: {
      title: '申请股份',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/allAgreement',
    name: 'allAgreement',
    component: () => import('@/views/groupStock/commonUser/allAgreement'),
    meta: {
      title: 'all协议',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/groupFund',
    name: 'groupFund',
    component: () => import('@/views/groupFund/groupFund'),
    meta: {
      title: '集团基金',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    // 动态路由
    path: '/cash/reflect/:id',
    name: 'cashReflect',
    component: () => import('@/views/groupStock/reflect'),
    meta: {
      title: '提现',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/groupStock/generalRecord',
    name: 'generalRecord',
    component: () => import('@/views/groupStock/generalRecord'),
    meta: {
      title: '总记录',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/reCharge/groupStock',
    name: 'reCharge',
    component: () => import('@/views/groupStock/reCharge'),
    meta: {
      title: '资本充值',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/groupStock/question',
    name: 'question',
    component: () => import('@/views/groupStock/question'),
    meta: {
      title: '常见问题',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/groupStock/understandGroup',
    name: 'understandGroup',
    component: () => import('@/views/groupStock/understandGroup'),
    meta: {
      title: '了解集团股份',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/groupStock/stockMarket',
    name: 'stockMarket',
    component: () => import('@/views/groupStock/stockMarket'),
    meta: {
      title: '股份市场',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/groupStock/notice',
    name: 'notice',
    component: () => import('@/views/groupStock/notice'),
    meta: {
      title: '公告信息',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/groupStock/projectIntro',
    name: 'projectIntro',
    component: () => import('@/views/groupStock/projectIntro'),
    meta: {
      title: '项目介绍',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/groupStock/tradeRecords',
    name: 'tradeRecords',
    component: () => import('@/views/groupStock/tradeRecords'),
    meta: {
      title: '买卖详情记录',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/groupStock/bonusRecords',
    name: 'bonusRecords',
    component: () => import('@/views/groupStock/bonusRecords'),
    meta: {
      title: '分红记录',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/groupStock/buyRecords',
    name: 'buyRecords',
    component: () => import('@/views/groupStock/buyRecords'),
    meta: {
      title: '派发记录',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/groupStock/deductRecords',
    name: 'deductRecords',
    component: () => import('@/views/groupStock/deductRecords'),
    meta: {
      title: '扣除记录',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/groupStock/reviewStockRecord',
    name: 'reviewStockRecord',
    component: () => import('@/views/groupStock/reviewStockRecord'),
    meta: {
      title: '(待我)审核的申请',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/groupStock/allUserAuditRecords',
    name: 'allUserAuditRecords',
    component: () => import('@/views/groupStock/allUserAuditRecords'),
    meta: {
      title: '(单个申请的)全部审核记录',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/groupStock/buyHistory',
    name: 'buyHistory',
    component: () => import('@/views/groupStock/buyHistory'),
    meta: {
      title: '买入记录',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/groupStock/sellRecords',
    name: 'sellRecords',
    component: () => import('@/views/groupStock/sellRecords'),
    meta: {
      title: '卖入记录',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/groupStock/buyStock',
    name: 'buyStock',
    component: () => import('@/views/groupStock/buyStock'),
    meta: {
      title: '买入股份',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/groupStock/buyTake',
    name: 'buyTake',
    component: () => import('@/views/groupStock/buyTake'),
    meta: {
      title: '申请股份',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/groupStock/sellStock',
    name: 'sellStock',
    component: () => import('@/views/groupStock/sellStock'),
    meta: {
      title: '卖出股份',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  // 个人用户点招聘信息详情查看公司需求
  {
    path: '/company/:id',
    name: 'companyDemand',
    component: () => import('../views/company/companyDemand'),
    meta: {
      title: '搜索本公司信息',
      keepAlive: false,
      isShowTabBar: false
    }
  },
  //用户查看公司介绍
  {
    path: '/companyIntroduce/:id',
    name: 'companyIntroduce',
    component: () => import('@/views/company/companyIntroduce'),
    meta: {
      title: '公司介绍',
      keepAlive: false,
      isShowTabBar: false
    }
  },
  //公司搜索页面
  {
    path: '/search/:id',
    name: 'searchCompany',
    component: () => import('../views/company/companySearch'),
    meta: {
      title: '搜索',
      keepAlive: false,
      isShowTabBar: false,
      isSearch: true
    }
  },
  //公司搜索全部内容
  {
    path: '/searchDetail/:id',
    name: 'SearchDetail',
    component: () => import('../views/company/companySearchDetail'),
    meta: {
      title: '详情',
      keepAlive: false,
      isShowTabBar: false,
      isSearch: false //控制搜索导航的返回
    }
  },
  //公司公告搜索页面
  {
    path: '/searchNotice/:id',
    name: 'searchNotice',
    component: () => import('@/views/company/searchNotice'),
    meta: {
      title: '搜索',
      keepAlive: false,
      isShowTabBar: false,
      isSearch: true
    }
  },
  //公司公告搜索详情页面
  {
    path: '/searchNoticeDetail/:id/:key/:type',
    name: 'searchNoticeDetail',
    component: () => import('../views/company/searchNoticeDetail'),
    meta: {
      title: '详情',
      keepAlive: false,
      isShowTabBar: false,
      isSearch: false //控制搜索导航的返回
    }
  },
  //我的公司公告搜索页面
  {
    path: '/searchMyNotice/:id',
    name: 'searchMyNotice',
    component: () => import('@/views/myCompany/companyHome/searchMyNotice'),
    meta: {
      title: '搜索',
      keepAlive: false,
      isShowTabBar: false,
      isSearch: true
    }
  },

  //公司公告
  {
    path: '/notice/:id',
    name: 'noticeCompany',
    component: () => import('../views/company/companyNotice'),
    meta: {
      title: '公告',
      keepAlive: false,
      isShowTabBar: false
    }
  },
  {
    path: '/demo',
    name: 'demo',
    // redirect: '/',
    component: () => import('@/views/demo/demo.vue'),
    meta: {
      title: 'demo练习页面--后续删除',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/resume',
    name: 'resume',
    component: () => import('@/views/resume/resume'),
    meta: {
      title: '简历',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: false
    }
  },
  {
    path: '/resumeDetailAdd',
    name: 'resumeDetailAdd',
    component: () => import('@/views/resumeDetail/resumeDetailAdd'),
    meta: {
      title: '个人简历填写',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: false
    }
  },
  {
    path: '/resumeDetail/:id',
    name: 'resumeDetail',
    component: () => import('@/views/resumeDetail/resumeDetail'),
    meta: {
      title: '个人简历详情',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: false
    }
  },
  {
    path: '/comRecruit',
    name: 'comRecruit',
    component: () => import('@/views/comRecruit/comRecruit'),
    meta: {
      title: '企业招聘',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: false
    }
  },
  {
    path: '/comRecruitAdd',
    name: 'comRecruitAdd',
    component: () => import('@/views/comRecruit/comRecruitAdd'),
    meta: {
      title: '个人简历填写',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: false
    }
  },
  {
    path: '/comRecruitDetail/:id',
    name: 'comRecruitDetail',
    component: () => import('@/views/comRecruit/comRecruitDetail'),
    meta: {
      title: '个人简历详情',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: false
    }
  },
  {
    path: '/collectionHistory',
    name: 'collectionHistory',
    component: () => import('../views/history/collectionHistory'),
    meta: {
      title: '收藏记录',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/jinpinHelper',
    name: 'jinpinHelper',
    component: () => import('../views/jinpinHelper/jinpinHelper'),
    meta: {
      title: '近聘助手',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: false
    }
  },
  {
    path: '/searchHelper',
    name: 'searchHelper',
    component: () => import('../views/jinpinHelper/searchHelper'),
    meta: {
      title: '近聘助手搜索',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: false
    }
  },
  {
    path: '/browsingHistory',
    name: 'browsingHistory',
    component: () => import('../views/history/browsingHistory'),
    meta: {
      title: '浏览记录',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: false
    }
  },
  {
    path: '/customerService',
    name: 'customerService',
    component: () => import('@/views/customerService/customerService'),
    meta: {
      title: '客服',
      keepAlive: false,
      isShowTabBar: false,
      requiresAuth: true
    }
  },
  {
    path: '/myAttention', //zhangyuming
    name: 'myAttention',
    component: () => import('../views/myAttention/myAttention'), // 路由懒加载
    meta: {
      title: '我的关注', // 页面标题
      keepAlive: false, // keep-alive 标识
      isShowTabBar: false,
      requiresAuth: true
    }
  },

  // 一定要写在最后
  {
    path: '*',
    redirect: '/'
  }
]

const router = new Router({
  // mode: 'history', // 如果你是 history模式 需要配置vue.config.js publicPath
  // base: '/app/',
  routes,
  scrollBehavior(to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition
    } else {
      if (from.meta.keepAlive) {
        from.meta.savedPosition = document.body.scrollTop
      }
      return {x: 0, y: to.meta.savedPosition || 0}
    }
  }
  /*scrollBehavior: () => ({ y: 0 }),*/
})

// 注册全局钩子用来路由守卫
router.beforeEach((to, from, next) => {
  let allCertificate = window.localStorage.getItem('allCertificate')
  // 必须登录才能看到的页面
  if (to.meta.requiresAuth) {
    // 有登录凭证才能看到
    if (allCertificate) {
      // store.dispatch('getAccountName')
      next()
    } else {
      store.dispatch('logOut')
      Dialog.confirm({
        message: '此功能需要注册登入才能使用，为您跳转到注册登入页面。'
      })
        .then(() => {
          if(to.fullPath.indexOf('unReceivedStock')>-1){
            next({
              path: '/login',
              query: {redirect: from.fullPath}
            })
          }else{
            next({
              path: '/login',
              query: {redirect: to.fullPath}
            })
          }
          
        })
        .catch(() => {
          // on cancel
        })
    }
  } else {
    // 不需要登录就能看到的页面
    next()
  }
})

export default router
